package com.wangping.processors;
/*
 * The following sets of letters are considered equivalent
   A,E,I,O,U
   C,G,J,K,Q,S,X,Y,Z
   B,F,P,V,W
   D,T
   M,N
   All others have no equivalent
 */
public class EquivalentProcessor extends Processor4List implements IProcessor, IProcessor4List {
	//A,E,I,O,U
	public static final String SET_1 = "AEIOU";
	//C,G,J,K,Q,S,X,Y,Z
	public static final String SET_2 = "CGJKQSXYZ";
	//B,F,P,V,W
	public static final String SET_3 = "BFPVW";
	//D,T
	public static final String SET_4 = "DT";
	//M,N
	public static final String SET_5 = "MN";
	
	private static String[] sets = {SET_1,SET_2,SET_3,SET_4,SET_5};
	
	public String process(String str) {
		char[] chars = str.toCharArray();
		for (int i = 0; i<chars.length; i++) {
			char c = chars[i];
			for (String set_x : sets) {
				if(set_x.indexOf(c) != -1){
					str = str.replace(c, set_x.charAt(0));
				}
			}
		}
		return str;
	}
	
	public static void main(String[] args) {

	}

}